<!DOCTYPE html>
<html class="no-js" lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>找回密码</title>

    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="shortcut icon" type="image/png" th:href="@{/assets/images/icon/favicon.ico}">
    <link rel="stylesheet" th:href="@{/assets/css/bootstrap.min.css}">
    <link rel="stylesheet" th:href="@{/assets/css/font-awesome.min.css}">
    <link rel="stylesheet" th:href="@{/assets/css/themify-icons.css}">
    <link rel="stylesheet" th:href="@{/assets/css/metisMenu.css}">
    <link rel="stylesheet" th:href="@{/assets/css/owl.carousel.min.css}">
    <link rel="stylesheet" th:href="@{/assets/css/slicknav.min.css}">
    <ink rel="stylesheet" th:href="@{/assets/css/export.css}" type="text/css" media="all"/>
    <link rel="stylesheet" th:href="@{/assets/css/typography.css}">
    <link rel="stylesheet" th:href="@{/assets/css/default-css.css}">
    <link rel="stylesheet" th:href="@{/assets/css/styles.css}">
    <link rel="stylesheet" th:href="@{/assets/css/responsive.css}">
    <script th:src="@{/assets/js/vendor/modernizr-2.8.3.min.js}"></script>

    <script>
        function submitFormWithCaptcha() {
            // 直接生成一个验证码对象
            var captcha = new TencentCaptcha('2046758645', function (res) {
                console.log(res)
                // res（未通过验证）= {ret: 1, ticket: null}
                // res（验证成功） = {ret: 0, ticket: "String", randstr: "String"}
                if (res.ret === 0) {
                    console.log("get form")
                    var form = document.getElementById('form1');
                    console.log("get ticket")
                    var ticketInput = document.getElementById("ticket");
                    console.log("get rnadstr")
                    var randstrInput = document.getElementById("randStr");
                    console.log(res.ticket)
                    ticketInput.value = res.ticket;
                    console.log("input randstr")
                    randstrInput.value = res.randstr;
                    console.log("submit")
                    form.submit();
                } else {
                    alert("验证失败");
                }
            });
            // 显示验证码
            captcha.show();
        }
    </script>
</head>
<body>
<div id="preloader">
    <div class="loader"></div>
</div>
<div class="login-area">
    <div class="container">
        <div class="login-box ptb--100">
            <form id="form1" class="form" th:action="@{/getPassword}" method="post">
                <div class="login-form-head">
                    <h4>找回密码</h4>
                </div>
                <div class="login-form-body">
                    <div class="form-gp">
                        <label for="exampleInputName1">账号</label>
                        <input type="number" id="exampleInputName1" name="userid">
                        <i class="ti-user"></i>
                    </div>
                    <div class="form-gp">
                        <label for="exampleInputText1">用户名</label>
                        <input type="text" name="username" id="exampleInputText1">
                        <i class="ti-lock"></i>
                    </div>

                    <span style="color: #190af1;font-size: 17px;font-weight: bold;" th:text="${password1}"></span>
                    <span style="color: red;font-size: 17px;font-weight: bold;" th:text="${errorMsg}"></span>


                    <input id="ticket" name="ticket" type="hidden" value="">
                    <input id="randStr" name="randStr" type="hidden" value="">
                    <div class="submit-btn-area">
                        <button type="button" onclick='submitFormWithCaptcha()'>找回密码</button>
                    </div>
                    <div class="submit-btn-area">
                        <button type="button" onclick="location='/login'">返回登录</button>
                    </div>
                </div>
            </form>

        </div>
    </div>
</div>
<script th:src="@{/assets/js/vendor/jquery-2.2.4.min.js}"></script>
<script th:src="@{/assets/js/popper.min.js}"></script>
<script th:src="@{/assets/js/bootstrap.min.js}"></script>
<script th:src="@{/assets/js/owl.carousel.min.js}"></script>
<script th:src="@{/assets/js/metisMenu.min.js}"></script>
<script th:src="@{/assets/js/jquery.slimscroll.min.js}"></script>
<script th:src="@{/assets/js/jquery.slicknav.min.js}"></script>
<script th:src="@{/assets/js/plugins.js}"></script>
<script th:src="@{/assets/js/scripts.js}"></script>
<script th:src="@{https://ssl.captcha.qq.com/TCaptcha.js}"></script>
</body>
</html>